# Requests 入门
# Requests 模块：python 中原生的一款基于网络请求的模块，功能非常强大，简单便捷，效率极高。
#          作用：模拟浏览器发请求。
# pip install requests
# 国内源：pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests

import requests

query = input('请输入一个你喜欢的明星：')
url = f'https://cn.bing.com/search?q={query}'
headers = {
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
}
resp = requests.get(url, headers=headers)   # 处理一个小小的反爬虫
# print(resp)
# print(resp.text)

with open(f'../爬虫文件/{query}.html', mode='w', encoding='utf-8') as file:
    file.write(resp.text)  # 读取爬到网页的源代码

print('over')
resp.close()